package com.craftplay.dao;

import com.craftplay.model.BehaveModel;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface BehaveMapper {

    @Insert({
            "insert into behave ( userId, ",
            "buserId, behave,createTime,unitId,isRead  )",
            "values (#{userId,jdbcType=INTEGER}, #{buserId,jdbcType=INTEGER}, ",
            "#{behave,jdbcType=VARCHAR}, #{createTime,jdbcType=DATE}, ",
            "#{unitId,jdbcType=INTEGER},#{isRead,jdbcType=INTEGER})"
    })
    int insert(BehaveModel record);


    @Select({
            "select",
            "*",
            "from behave",
            "where userId=#{userId} and isRead=#{isRead} and buserId!=#{userId} order by createTime desc "
    })
    List<BehaveModel> getBehaveList(@Param(value = "userId") Integer userId,@Param(value = "isRead") Integer isRead);


    @Update({
            "update behave",
            "set isRead=1",
            "where bId = #{bId,jdbcType=INTEGER}"
    })
    void isRead(BehaveModel behaveModel);


    @Delete({
            "delete from behave",
            "where bId = #{bId,jdbcType=INTEGER}"
    })
    void deleteBehave(BehaveModel behaveModel);
}